package com.ljq.cksp;

import com.ljq.cksp.dao.BookDao;
import com.ljq.cksp.dao.ChapterDao;
import com.ljq.cksp.dao.DocumentDao;
import com.ljq.cksp.dao.LawDao;
import com.ljq.cksp.pojo.*;
import com.ljq.cksp.util.JsonUtil;
import com.ljq.cksp.util.PythonUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.File;
import java.util.List;
import java.util.Properties;


/**
 * @Author:ljq
 * @Date:2020/2/9
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SkspApplication.class)
public class Init {
    @Autowired
    LawDao lawDao;
    @Autowired
    DocumentDao documentDao;
    @Autowired
    JsonUtil jsonUtil;
    @Autowired
    BookDao bookDao;

    @Test
    public void lawInit()throws Exception {
        lawDao.deleteAll();
        File file = new File("C:/Users/75231/Desktop/law/刑法.json");
        lawDao.saveAll(JsonUtil.json2Laws(file));
    }

    @Test
    public void documentInit()throws Exception {
        documentDao.deleteAll();
        File file = new File("C:/Users/75231/Desktop/law/data_valid.json");
        documentDao.saveAll(JsonUtil.json2Documents(file));
    }


    @Autowired
    ChapterDao chapterDao;
    @Test
    public void bookInit()throws Exception {
        bookDao.deleteAll();
        File file = new File("C:/Users/75231/Desktop/law/刑法.json");
        bookDao.save(JsonUtil.json2Book(file));
    }
}
